<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

if(!empty($_GET['did'])){
	
	$did= $_GET['did'];
	$GLOBALARR['curl'] = YMCURL.'rolelist';
	$db->sitedbexec("delete from ld_privilege where edid = $did");

	record_log('删除角色');
	show_automsg('删除角色成功！',$GLOBALARR['curl']);
}

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$option=getnums($_GET['option'],1);
$orderby=getnums($_GET['orderby'],1);
$quser=trim($_GET['quser']);

$tmp_arr['toption'].='<a href="'.YMCURL.'roleadd" class="'.geteqval(array($option,2,'taselbtn','thabtn')).'">添加角色</a>';

$condition=' where 1=1 ';


$tmp_arr['tth']='<th>序号</th><th>角色名称</th><th >状态</th><th>操作</th>';

$psql="select count(0) from ld_privilege $condition";
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=rolelist&pagecount=$pagecount&orderby=$orderby&option=$option&quser=$quser";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];

$sql="select * from ld_privilege  $condition order by edid limit $offset,$pagecount";
$db->query($sql);
$ii=0;
foreach ($db->rs as $k => $v) {
	$ii++;
	$serialid=($pagearr[2]-1)*$pagecount+$ii;
	
	$zhuangtai = ($v['status']==0)?'正常':'禁止';
	$tmp_arr['ttr'].='<tr class="levelcolor">
						
						<td><span  title="'.$v["edid"].'">'.$serialid.'</span></td>
						<td>'.$v['rolename'].'</td>
						<td>'.$zhuangtai.'</td>
					
						<td><a href= "'.YMCURL.'roleedit&edid='.$v['edid'].'">修改</a>&nbsp;<a href = "'.YMCURL.'rolelist&did='.$v['edid'].'">删除</a></td>
						</tr>';
}


$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'controllist');
$tmp_arr['tpage']=$pagearr[0];
admin_three($tmp_arr);

?>